package duaxe.home.entity.mob;

import java.util.ArrayList;
import java.util.List;

import duaxe.home.Graphics.Sprite;
import duaxe.home.entity.Entity;
import duaxe.home.entity.particle.Particle;
import duaxe.home.entity.projectile.Projectile;
import duaxe.home.entity.projectile.WizardProjectile;

public class Mob extends Entity {
	protected Sprite sprite;
	protected int dir = 0;
	protected boolean moving = false;
	protected boolean walking = false;
	
//	protected List<Projectile> projectiles = new ArrayList<Projectile>();  

	public void move(int xa, int ya) {
		// if(xa !=0 && ya !=0){
		// move(xa, 0);
		// move(0, ya);
		// return;
		// }

		if (xa > 0)
			dir = 1;
		if (xa < 0)
			dir = 3;
		if (ya > 0)
			dir = 2;
		if (ya < 0)
			dir = 0;

		if (!collision(xa, ya)) {
			x += xa;
			y += ya;
		}
//		}else{
//			Particle p = new Particle(x, y, 50, 500);
//			level.add(p);
//		}
	}

	public void update() {

	}
	protected void shoot(int x, int y, double dir){
//		dir *= 180/Math.PI;
//		System.out.println("Home: "+ dir);
		Projectile p = new WizardProjectile(x, y, (int)dir); 
		//projectiles.add(p);
		level.add(p);
		
	}

	private boolean collision(int xa, int ya) {
		boolean solid = false;
		for (int c = 0; c < 4; c++) {
			int xt = ((x + xa) + c / 2 * 14 - 8) / 16;
			int yt = ((y + ya) + c / 2 * 14 - 8) / 16;
			if (level.getTile(xt, yt).solid()) {
				solid = true;
			}
		}
		return solid;
	}

	public void render() {

	}
}
